home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / dev / c / libiconv_src.lha / src / genaliases2.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-07  |  1.9 KB  |  62 lines

  1. /* Copyright (C) 1999-2000 Free Software Foundation, Inc.
  2.    This file is part of the GNU ICONV Library.
  3.  
  4.    The GNU ICONV Library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public License as
  6.    published by the Free Software Foundation; either version 2 of the
  7.    License, or (at your option) any later version.
  8.  
  9.    The GNU ICONV Library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public
  15.    License along with the GNU ICONV Library; see the file COPYING.LIB.  If not,
  16.    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.    Boston, MA 02111-1307, USA.  */
  18.  
  19. /* Creates the aliases2.h table. */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23.  
  24. static void emit_encoding (const char* const* names, size_t n, const char* c_name)
  25. {
  26.   for (; n > 0; names++, n--) {
  27.     printf("  { \"");
  28.     /* Output *names in upper case. */
  29.     {
  30.       const char* s = *names;
  31.       for (; *s; s++) {
  32.         unsigned char c = * (unsigned char *) s;
  33.         if (c >= 0x80)
  34.           exit(1);
  35.         if (c >= 'a' && c <= 'z')
  36.           c -= 'a'-'A';
  37.         putc(c, stdout);
  38.       }
  39.     }
  40.     printf("\", ei_%s },\n", c_name);
  41.   }
  42. }
  43.  
  44. int main ()
  45. {
  46. #define DEFENCODING(xxx_names,xxx,xxx_ifuncs,xxx_ofuncs1,xxx_ofuncs2) \
  47.   {                                                           \
  48.     static const char* const names[] = BRACIFY xxx_names;     \
  49.     emit_encoding(names,sizeof(names)/sizeof(names[0]),#xxx); \
  50.   }
  51. #define BRACIFY(...) { __VA_ARGS__ }
  52. #ifdef USE_AIX
  53. #include "encodings_aix.def"
  54. #endif
  55. #undef BRACIFY
  56. #undef DEFENCODING
  57.   fflush(stdout);
  58.   if (ferror(stdout))
  59.     exit(1);
  60.   exit(0);
  61. }
  62.